use std::env;
use std::process;
use std::fs::File;
use std::io::BufReader;
use std::io::BufRead;

fn main() {
    let args: Vec<String> = env::args().collect();
    if args.len() < 2 {
        println!("Too few arguments.");
        process::exit(1);
    }
    let filename = &args[1];
    // Your code here :)
    let file = File::open(filename).expect("file not found");
    let mut cnt_line = 0;
    let mut cnt_word = 0;
    let mut cnt_char = 0;
    
    for line in BufReader::new(file).lines() {
        let line = line.expect("error reading line");
        cnt_line += 1;
        cnt_word += line.split_whitespace().count();
        cnt_char += line.len();
    }
    println!("  {} {} {} {}", cnt_line, cnt_word, cnt_char, filename);

}
